package com.central.user.mapper;

import com.central.common.model.SysDepartment;
import com.central.db.mapper.SuperMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 菜单
 *
 * @author td
 */
@Mapper
public interface SysDepartmentMapper extends SuperMapper<SysDepartment> {

    /**
     * 获取子部门
     * @param parentId
     * @return
     */
    @Select("select * from sys_department d where parent_id=#{parentId}")
    List<SysDepartment> findSubs(@Param("parentId")Long parentId);

    @Select("select d.* from sys_department d inner join sys_user u on d.id=u.department_id and u.id=#{userId}")
    SysDepartment findByUserId(Long userId);
}
